import { userGetInfoServices } from '@/api/user'
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useUserStore = defineStore('bigUser', () => {
    const token = ref('')
    const user = ref({})
    const getUser = async () => {
        const res = await userGetInfoServices()
        user.value = res.data.data
    }
    const removeUser = () => user.value = {}
    const setToken = (newToken) => {
        token.value = newToken
    }
    const removeToken = () => {
        token.value = ''
    }
    return {
        token,
        setToken,
        removeToken,
        getUser,
        user,
        removeUser
    }
}, {
    persist: true // 持久化
})